package com.kantboot.file.config;

import com.alibaba.fastjson.JSON;
import com.kantboot.file.entity.TypeManage;
import lombok.Data;
import lombok.SneakyThrows;
import lombok.Synchronized;
import lombok.experimental.Accessors;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;
import org.springframework.util.ResourceUtils;

import java.io.*;

@Data
@Accessors(chain = true)
public class KantbootFileSettingConfig{

    /**
     * 文件上传位置
     */
    private String uploadPath;

    @SneakyThrows
    public static KantbootFileSettingConfig newInstance() {
        BufferedReader bufferedReader
                =new BufferedReader(new InputStreamReader(
                new FileInputStream(
                        ResourceUtils
                                .getFile("classpath:config/KantbootFileSettingConfig.json"))
        ));
        String data="";
        String str="";
        while((data = bufferedReader.readLine()) != null) {
            str+=data;
        }
        bufferedReader.close();
        KantbootFileSettingConfig kantbootFileSettingConfig = JSON.parseObject(str, KantbootFileSettingConfig.class);
        return kantbootFileSettingConfig;
    }

}
